package com.lap.auth.domain.menu.service;

import com.lap.auth.domain.menu.Menu;
import com.lap.auth.domain.menu.repository.MenuRepository;
import com.lap.auth.shared.errors.UserError;
import com.lap.framework.common.exception.BizException;
import lombok.RequiredArgsConstructor;

@RequiredArgsConstructor
public class MenuValidator {

  private final MenuRepository menuRepository;

  public Menu assertMenuExists(Integer id) {
    return menuRepository
        .findById(id)
        .orElseThrow(() -> BizException.newBiz(UserError.MENU_NOT_FOUND));
  }
}
